package oneD.fem.element;

import oneD.fem.Node;
import inf.jlinalg.ArrayVector;
import inf.jlinalg.IMatrix;
import inf.jlinalg.IVector;

public class Element {
	protected Node[] node_;
	protected int[] dofNumbers_;
	private int id;

	public void setId(int i) {
		this.id = i;
	}

	public int getId() {
		return this.id;
	}

	public Node getNode(int idx) {
		return this.node_[idx];
	}

	public IVector getXe() {
		int numNode = this.node_.length;
		IVector Xe = new ArrayVector(3 * numNode);
		for (int i = 0; i < numNode; i++) {
			double[] xei = this.getNode(i).getPosition().toArray();
			for (int j = 0; j < 3; j++)
				Xe.set(3 * i + j, xei[j]);
		}
		return Xe;
	}

	public IVector getUe() {
		int numNode = this.node_.length;
		IVector Ue = new ArrayVector(3 * numNode);
		for (int i = 0; i < numNode; i++) {
			double[] uei = this.getNode(i).getDisplacement().toArray();
			for (int j = 0; j < 3; j++)
				Ue.set(3 * i + j, uei[j]);
		}
		return Ue;
	}

	public void enumerateDOFs() {
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 3; j++)
				this.dofNumbers_[3 * i + j] = this.node_[i].getDOFNumbers()[j];
	}

	public int[] getDOFNumbers() {
		return this.dofNumbers_;
	}

	public IMatrix computeStiffnessMatrix() {
		return null;
	}// this is used for linear element

	public IMatrix computeMassMatrix() {
		return null;
	}

	public IMatrix computeGeometricalStiffnessMatrix() {
		return null;
	}

	public IMatrix computeTangentStiffnessMatrix() {
		return null;
	}

	public IVector computeInternalForcesVector() {
		return null;
	}

	public double computeForce() {
		return 0.0;
	}// this routine is used for truss-type element only

	public double getArea() {
		return 0.0;
	}// this routine is used for truss-type element only

	public void print() {
		System.out.println("This is an element");
	}

	public void setPreStress(double stress) {

	}

}
